<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8" />
		<title>权限管理系统系统后台登录</title>
		<link rel="stylesheet" type="text/css" href="css/index.css" />
		<script src="js/global.js"></script>
	</head>

	<body>

		<img class="bgone" src="img/1.jpg" />
		<img class="pic" src="img/a.png" />

		<form class="layui-form" action="">
			<div class="wel">权限管理系统系统后台登录</div>
			<div class="wel1">QUAN XIAN GUAN LI XI TONG HOU TAI DENG LU</div>
			<div class="user">
				<div id="yonghu" style=""><img src="img/yhm.png" /></div>
				<input type="text" name="loginName" value="" required lay-verify="required" placeholder="请输入用户名" >
			</div>
			<div class="password">
				<div id="yonghu"><img src="img/mm.png" /></div>
				<input type="password" name="password" value="" required lay-verify="required" placeholder="请输入密码">
			</div>
			<button class="btn" lay-submit lay-filter="formDemo">登录</button>
		</form>



	<script>
			//Demo
			layui.use('form', function() {
				var form = layui.form;

				//监听提交
				form.on('submit(formDemo)', function(data) {
					//layer.msg(JSON.stringify(data.field));
					console.log(data.field);
					$.post(globalData.server + "login", data.field, function(res) {
						console.log(res);
						if(res != null && res.code==0) {//登录成功
							//保存token
							globalData.setToken(res.token)
							//保存登录成功的用户信息
							globalData.setUserInfo(res.data.id, res.data.loginName)
							console.log(globalData.getToken());
							//跳转到index页面
							window.location.href = "index.html";
						}else{
							layer.alert(res.msg);
						}
					})

					//不提交表单
					return false;
				});
			});
		</script>
	</body>

</html>